package main

import (
	"gitee.com/wu-jin-feng/fgin"
	reflectPb "gitee.com/wu-jin-feng/fgin/demos/fplugs_test/pb"
	"gitee.com/wu-jin-feng/fgin/demos/fplugs_test/plugs"
	_ "gitee.com/wu-jin-feng/fgin/demos/fplugs_test/plugs"
	"github.com/gin-gonic/gin"
)

func getGrpc(f *fgin.Fgin) reflectPb.DemoServiceClient {
	grpcConn, err := f.GetFgrpcClientConn("test_grpc")
	if err != nil {
		panic(err)
	}
	c := reflectPb.NewDemoServiceClient(grpcConn)
	return c
}

func main() {
	f := fgin.Fgin{}
	r := f.GetHttpServer("./test.yaml")
	plugs.MysqlRegisteFginLog(f.GetFginLogger())
	// 拿到grpcclient
	// c := getGrpc(&f)
	r.GET("haha", func(ctx *gin.Context) {
		plugs.MysqlInfo("plugs mysql 使用fgin logger hahahha")
		fgin.ReturnJson(ctx, 200, "哈哈哈", nil)
	})
	/*r.GET("hhh", func(ctx *gin.Context) {
		params := reflectPb.GetSchemeReq{
			Path: "321222",
			Info: &reflectPb.GetSchemeRespInfo{
				Info: "哈哈哈哈",
				Name: "gogo",
			},
		}
		res, err := c.GetScheme(ctx, &params)
		if err != nil {
			fgin.ReturnJson(ctx, 403, "fail", err)
		}
		fgin.ReturnJson(ctx, 200, res, nil)
	})*/

	f.Run(r)
}
